package home.my.base.sql;

import java.io.Serializable;

import org.apache.commons.lang.StringUtils;

public abstract class AbsCondition {
	private String tableAlias;
	private String column;
	private String equalChar;
	private Serializable value;
	
	public String getEqualChar() {
		return equalChar;
	}
	public void setEqualChar(String equalChar) {
		this.equalChar = equalChar;
	}
	public Serializable getValue() {
		return value;
	}
	public void setValue(Serializable value) {
		this.value = value;
	}
	public String getColumn() {
		return column;
	}
	public void setColumn(String column) {
		this.column = column;
	}
	
	public String getTableAlias(){
		if(StringUtils.isBlank(tableAlias)){
			return "t";
		}else{
			return tableAlias;
		}
	}
	public void setTableAlias(String tableAlias) {
		this.tableAlias = tableAlias;
	}
	
	public String getColumnWithTableName(){
		StringBuffer buffer = new StringBuffer();
		buffer.append(getTableAlias());
		buffer.append(".");
		buffer.append(this.getColumn());
		return buffer.toString();
	}
	
	public String toSql(){
//		StringBuilder valueSql = new StringBuilder();
//		if(value==null){
//			
//		}else if(value instanceof String){
//			valueSql.append("'").append(valueSql).append("'");
//		}else if(value instanceof Number){
//			valueSql.append(value);
//		}else if(value instanceof java.util.Date){
//			valueSql.append(((java.util.Date) value).getTime());
//		}
//		return getColumnWithTableName() + " " +getEqualChar() + " " + valueSql;
		return getColumnWithTableName() + " " +getEqualChar() + " ? ";
	}
}
